Skip to content

put country setters in right places#225

Merged
andrewbaxter439 merged 1 commit into
developfrom
bugfix/224-develop-branch-in-multirun-setup-doesnt-create-country-before-referencing-it
Aug 8, 2025
Merged

put country setters in right places#225
andrewbaxter439 merged 1 commit into
developfrom
bugfix/224-develop-branch-in-multirun-setup-doesnt-create-country-before-referencing-it

Conversation

@andrewbaxter439

Copy link
Copy Markdown
Collaborator

What

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes country setter placement by moving the Country.getCountryFromNameString(countryString) assignment to occur before it's used in the database lookup, addressing issue #224.

  • Moves country initialization to happen before the country variable is used in line 89
  • Adds country initialization in the exception handler to ensure it's always set

Comment on lines +88 to +94
country = Country.getCountryFromNameString(countryString);
String valueYear = lastDatabaseCountryAndYear.getValue(country.toString()).toString();
startYear = Integer.parseInt(valueYear);
} catch (NullPointerException e) {
System.out.println("No last database country and year found.");
countryString = "United Kingdom";
country = Country.getCountryFromNameString(countryString);

Copilot AI Aug 6, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The country variable is used here but may still be null if an exception occurs during the Country.getCountryFromNameString() call on line 88, which would cause a NullPointerException.

Suggested change
country = Country.getCountryFromNameString(countryString);
String valueYear = lastDatabaseCountryAndYear.getValue(country.toString()).toString();
startYear = Integer.parseInt(valueYear);
} catch (NullPointerException e) {
System.out.println("No last database country and year found.");
countryString = "United Kingdom";
country = Country.getCountryFromNameString(countryString);
country = Country.getCountryFromNameString(countryString);
if (country == null) {
country = Country.UNITED_KINGDOM;
}
String valueYear = lastDatabaseCountryAndYear.getValue(country.toString()).toString();
startYear = Integer.parseInt(valueYear);
} catch (NullPointerException e) {
System.out.println("No last database country and year found.");
countryString = "United Kingdom";
country = Country.getCountryFromNameString(countryString);
if (country == null) {
country = Country.UNITED_KINGDOM;
}

Copilot uses AI. Check for mistakes.
@andrewbaxter439 andrewbaxter439 merged commit d7ea260 into develop Aug 8, 2025
5 checks passed
@andrewbaxter439 andrewbaxter439 deleted the bugfix/224-develop-branch-in-multirun-setup-doesnt-create-country-before-referencing-it branch January 6, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

develop branch in multirun setup doesn't create country before referencing it

2 participants